home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / ny_010w1.zip / NY_JPSRC.ZIP / JACKPOT.CPP < prev    next >
C/C++ Source or Header  |  1995-09-21  |  16KB  |  590 lines

  1. //Include the header file
  2. #include "jackpot.h"
  3.  
  4. //fuction prototypes
  5. unsigned long get_val(unsigned long def, unsigned long max);
  6.   //ny2008 value entering system
  7.  
  8. void strzcpy(char dest[],const char src[], int beg,int end);
  9.   //copy characters from a middle of a string
  10.  
  11. char *ny_un_emu(const char line[],char out[]);
  12.   //remove color codes from line[] and out put to out[]
  13.  
  14. int main(int argc,char *argv[]);
  15.   // main fuction
  16.  
  17. int main(int argc,char *argv[])
  18. {
  19.   FILE *file_handle;          //file handle
  20.   char key;                   //single character for menu choice
  21.   char *char_in_string;       //character pointer used in terminating strings
  22.   unsigned int money;         //money that was bet
  23.   unsigned long jackpot;      //the jackpot
  24.   user_rec urec;              //user record
  25.   unsigned int chance;        //the chance variable ... will store a random num
  26.   unsigned int max_bet;       //maximum bet
  27.   unsigned int set_ch=20000;  //average winable jackpot
  28.   int intval;                 //temporary int variable
  29.   char tmp_str_1[61],tmp_str_2[35];//temporary strings
  30.   char dfile1[74],dfile2[74]; //dropfile names
  31.   ffblk ff;                   //ffblk
  32.   int ans_t,avt_t;            //ANSI?,AVATAR? Boolean values
  33.   int x,x2;                   //for loop counters
  34.   char path[60];              //path to drop files
  35.   int user_num;               //user number
  36.  
  37.  
  38.   //registration (enter you opendoors reg key here)
  39.   strcpy(od_registered_to,"Nobody");
  40.   od_registration_key=0000000000000;
  41.  
  42.   //do not use direct video writes
  43.   directvideo=0;
  44.  
  45.   //include config file
  46.   od_control.od_config_file = INCLUDE_CONFIG_FILE;
  47.   od_control.od_config_filename = "JACKPOT.CFG";
  48.  
  49.   //include multiple personality system
  50.   od_control.od_mps=INCLUDE_MPS;
  51.   od_control.od_nocopyright=TRUE;
  52.  
  53.   //there was not enough arguments passed
  54.   if(argc<4) {
  55.     printf("\n\r\n\rJACKPOT:Not enough arguments\n\r\n\r");
  56.     exit(12);
  57.   }
  58.  
  59.   //argument #1 is the path to the drop files
  60.   strcpy(path,argv[1]);
  61.  
  62.   //get the second argument
  63.   x=2;
  64.  
  65.   //read all arguments and act accordingly
  66.   do {
  67.  
  68.     //game is local (NY2008's generic argument)
  69.     if (strnicmp(argv[x],"-L",2)==0) {
  70.       od_control.od_force_local=TRUE;
  71.  
  72.     //node number (NY2008's generic argument)
  73.     } else if (strnicmp(argv[x],"-N",2)==0) {
  74.       strzcpy(tmp_str_1,argv[x],2,59);
  75.       sscanf(tmp_str_1,"%d",&intval);
  76.       od_control.od_node=intval;
  77.  
  78.     //average jackpot winable size
  79.     } else if (strnicmp(argv[x],"-J",2)==0) {
  80.       strzcpy(tmp_str_1,argv[x],2,59);
  81.       sscanf(tmp_str_1,"%u",&set_ch);
  82.  
  83.     // user number (NY2008's generic argument)
  84.     } else if (strnicmp(argv[x],"-U",2)==0) {
  85.       strzcpy(tmp_str_1,argv[x],2,59);
  86.       sscanf(tmp_str_1,"%d",&user_num);
  87.  
  88.     //use direct writes
  89.     } else if (strnicmp(argv[x],"-DV",3)==0) {
  90.       directvideo=1;
  91.  
  92.     //use a different .CFG file
  93.     } else if (strnicmp(argv[x],"-C",2)==0) {
  94.       strzcpy(od_control.od_config_filename,argv[x],2,59);
  95.     }
  96.  
  97.   //loop for all arguments
  98.   } while ((++x)<=argc);
  99.  
  100.   //do not read any drop files (will be read manually this is for odoors)
  101.   od_control.od_disable|=DIS_INFOFILE;
  102.  
  103.   //get length of path and check weather it includes a trailing slash
  104.   // if not then add it
  105.   x=strlen(path);
  106.   if (path[x-1]!='\\') {
  107.     path[x]='\\';
  108.     path[x+1]=0;
  109.   }
  110.  
  111.   //create drop file names
  112.   sprintf(dfile1,"%su%07d.inf",path,user_num);
  113.   sprintf(dfile2,"%sn%07d.sts",path,od_control.od_node);
  114.  
  115.   //if one or both are not found exit
  116.   if(findfirst(dfile1,&ff,0)!=0 * findfirst(dfile2,&ff,0)!=0) {
  117.     printf("\n\r\n\rJACKPOT:Game drop file(s) not found!\n\r\n\r");
  118.     exit(12);
  119.   }
  120.  
  121.   //open .inf file
  122.   file_handle=fopen(dfile1,"rt");
  123.  
  124.   //get first line (bbs dropfile path)
  125.   fgets(od_control.info_path,59,file_handle);
  126.   //get rid of the \n char in the string and make it 0
  127.   if((char_in_string=strchr(od_control.info_path,'\n'))!=0)
  128.     *char_in_string=0;
  129.  
  130.   //get second line (time limit)
  131.   fgets(tmp_str_1,30,file_handle);
  132.   //read in the value
  133.   sscanf(tmp_str_1,"%d",&od_control.caller_timelimit);
  134.  
  135.   //comport
  136.   fgets(tmp_str_1,30,file_handle);
  137.   sscanf(tmp_str_1,"%d",&od_control.port);
  138.  
  139.   //baud rate
  140.   fgets(tmp_str_1,30,file_handle);
  141.   sscanf(tmp_str_1,"%lu",&od_control.baud);
  142.  
  143.   //terminal emulation
  144.   fgets(tmp_str_1,30,file_handle);
  145.   //get rid of the \n char in the string and make it 0
  146.   if((char_in_string=strchr(tmp_str_1,'\n'))!=0)
  147.     *char_in_string=0;
  148.  
  149.   //set avt_t and ans_t according to tmp_str_1
  150.   //ansi
  151.   if(strcmp(tmp_str_1,"ANSI")==0) {
  152.     ans_t=TRUE;
  153.     avt_t=FALSE;
  154.   //avatar
  155.   } else if(strcmp(tmp_str_1,"AVATAR")==0) {
  156.     ans_t=TRUE;
  157.     avt_t=TRUE;
  158.   //ascii
  159.   } else {
  160.     ans_t=FALSE;
  161.     avt_t=FALSE;
  162.   }
  163.  
  164.   //get players location
  165.   fgets(od_control.user_location,25,file_handle);
  166.   //get rid of the \n char in the string and make it 0
  167.   if((char_in_string=strchr(od_control.user_location,'\n'))!=0)
  168.     *char_in_string=0;
  169.  
  170.   //is fossil used?
  171.   fgets(tmp_str_1,30,file_handle);
  172.   //get rid of the \n char in the string and make it 0
  173.   if((char_in_string=strchr(tmp_str_1,'\n'))!=0)
  174.     *char_in_string=0;
  175.  
  176.   //fossil used
  177.   if(strcmp(tmp_str_1,"FOSSIL")==0) {
  178.     od_control.od_com_method=COM_FOSSIL;
  179.  
  180.   //fossil not used read the comm settings
  181.   } else {
  182.     od_control.od_com_method=COM_INTERNAL;
  183.  
  184.     //get com address
  185.     fgets(tmp_str_1,30,file_handle);
  186.     sscanf(tmp_str_1,"%d",&od_control.od_com_address);
  187.  
  188.     //get irq
  189.     fgets(tmp_str_1,30,file_handle);
  190.     sscanf(tmp_str_1,"%d",&intval);
  191.     od_control.od_com_irq=intval;
  192.  
  193.     //use FIFO?
  194.     fgets(tmp_str_1,30,file_handle);
  195.     //get rid of the \n char in the string and make it 0
  196.     if((char_in_string=strchr(tmp_str_1,'\n'))!=0)
  197.       *char_in_string=0;
  198.  
  199.     //no fifo
  200.     if(strcmp(tmp_str_1,"NOFIFO")==0)
  201.       od_control.od_com_no_fifo=TRUE;
  202.  
  203.     //use fifo
  204.     else
  205.       od_control.od_com_no_fifo=FALSE;
  206.  
  207.     //fifo trigger size
  208.     fgets(tmp_str_1,30,file_handle);
  209.     sscanf(tmp_str_1,"%d",&intval);
  210.     od_control.od_com_fifo_trigger=intval;
  211.  
  212.     //recieve buffer
  213.     fgets(tmp_str_1,30,file_handle);
  214.     sscanf(tmp_str_1,"%u",&od_control.od_com_rx_buf);
  215.  
  216.     //transmit buffer
  217.     fgets(tmp_str_1,30,file_handle);
  218.     sscanf(tmp_str_1,"%u",&od_control.od_com_tx_buf);
  219.   }
  220.  
  221.   //close the .inf file
  222.   fclose(file_handle);
  223.  
  224.   //open the .sts file
  225.   file_handle=fopen(dfile2,"rb");
  226.  
  227.   //read in the user record
  228.   fread(&urec,sizeof(user_rec),1,file_handle);
  229.  
  230.   //close the .sts file
  231.   fclose(file_handle);
  232.  
  233.   //destroy emulation codes and put it in tmp_str_2
  234.   ny_un_emu(urec.name,tmp_str_2);
  235.  
  236.   //store this in user name so that the handle will display first and
  237.   //bbsname second. If you read any bbs drop files be sure to change it
  238.   //back before you exit.
  239.   sprintf(tmp_str_1,"%s (%s)",tmp_str_2,urec.bbsname);
  240.   strcpy(od_control.user_name,tmp_str_1);
  241.  
  242.   //display the copyright message (it won't really show but it will be there)
  243.   od_printf("`bright`New York 2008 Jackpot IGM, FREEWARE!\n\r(c) Copyright 1995, George Lebl - All rights Reserved\n\r");
  244.  
  245.   //se the ansi and avatar values
  246.   od_control.user_ansi=ans_t;
  247.   od_control.user_avatar=avt_t;
  248.  
  249.   //check if another node is using the IGM
  250.   if(findfirst("JACKPOT.USD",&ff,0)!=0) {
  251.     file_handle=fopen("JACKPOT.USD","wt");
  252.     fclose(file_handle);
  253.  
  254.   //if it is exit
  255.   } else {
  256.     od_printf("\n\r`bright red`T`red`he IGM is used by another node!\n\r`bright red`T`red`his IGM is not multinode capable!\n\r`bright red`C`red`ome back later!\n\r\n\r`bright red`Smack [Enter] to countinue:");
  257.     od_get_answer("\n\r");
  258.     od_exit(10,FALSE);
  259.   }
  260.  
  261.   //check if the dat file is there
  262.   //if not create it and make the jackpot 100
  263.   if(findfirst("JACKPOT.DAT",&ff,0)!=0) {
  264.     jackpot=100;
  265.     file_handle=fopen("JACKPOT.DAT","wt");
  266.     fprintf(file_handle,"100");
  267.     fclose(file_handle);
  268.  
  269.   //if yes read in the value
  270.   } else {
  271.     file_handle=fopen("JACKPOT.DAT","rt");
  272.     fscanf(f